import Vue from "vue";

import VueRouter from "vue-router";
import Layout from "../Layout.vue";

Vue.use(VueRouter);

const router = new VueRouter({
  mode: "hash",
  routes: [
    {
      path: "/home",
      name: "Home",
      component: Layout,
      redirect: { name: "HomeIndex" },
      children: [
        {
          path: "index",
          name: "HomeIndex",
          component: () => import("../HomeIndex.vue"),
        },
      ],
    },
    {
      path: "/shop",
      name: "Shop",
      component: Layout,
      redirect: { name: "ShopIndex" },
      meta: {
        cnName: "商城",
      },
      children: [
        {
          path: "index",
          name: "ShopIndex",
          meta: {
            cnName: "商城首页",
          },
          component: () => import("../ShopIndex.vue"),
        },
        {
          path: "detail",
          name: "ShopDetail",
          meta: {
            cnName: "商品详情",
          },
          component: () => import("../ShopDetail.vue"),
        },
        {
          path: "list",
          name: "ShopList",
          meta: {
            cnName: "商品列表",
          },
          component: () => import("../ShopList.vue"),
        },
      ],
    },
    {
      path: "/user",
      name: "User",
      component: Layout,
      redirect: { name: "UserIndex" },
      meta: {
        cnName: "用户",
      },
      children: [
        {
          path: "index",
          name: "UserIndex",
          meta: {
            cnName: "用户首页",
          },
          component: () => import("../UserIndex.vue"),
        },
      ],
    },
  ],
});

export default router;
